//
//  HHLeadInPagesCell.m
//  LeadInPages
//
//  Created by 花花 on 2016/12/11.
//  Copyright © 2016年 花花. All rights reserved.
//

#import "HHLeadInPagesCell.h"

@implementation HHLeadInPagesCell
-(void)awakeFromNib{
    [super awakeFromNib];
    [self commonInit];
}

-(instancetype)initWithCoder:(NSCoder *)aDecoder{

    if (self = [super initWithCoder:aDecoder]) {
        [self commonInit];
    }
    
    return self;
}

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self commonInit];
    }

    return self;
}

- (instancetype)init{

    if (self = [super init]) {
        [self commonInit];
    }
    return self;

}

-(void)layoutSubviews{

    [super layoutSubviews];
    
    
    self.imageView.frame = self.contentView.bounds;
    [self.finishbtn sizeToFit];
    CGFloat margin = 10;
    CGFloat finishW = self.finishbtn.bounds.size.width + 2 * margin;
    CGFloat finishH = self.finishbtn.bounds.size.height + 2 * margin;
    CGFloat finishX = (self.bounds.size.width - finishW)/2;
    CGFloat finishY = self.bounds.size.height - finishH - 100;
    
    self.finishbtn.frame =CGRectMake(finishX, finishY, finishW, finishH);

}
-(void)commonInit{

    [self.contentView addSubview:self.imageView];
    [self.contentView addSubview:self.finishbtn];

}

-(UIButton *)finishbtn{
    if (!_finishbtn) {
        UIButton *btn =[UIButton buttonWithType:UIButtonTypeCustom];
        btn.backgroundColor =[UIColor orangeColor];
        btn.layer.cornerRadius = 10.f;
        btn.layer.masksToBounds = YES;
        _finishbtn = btn;
    }
    return _finishbtn;
}

-(UIImageView *)imageView{

    if (!_imageView) {
        _imageView =[[UIImageView alloc]init];
        _imageView.contentMode = UIViewContentModeScaleAspectFill;
    }


    return _imageView;

}
@end
